package com.eastfair.venueservice.controller;

import com.eastfair.core.base.R;
import com.eastfair.venueservice.service.HomePageStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * The type Home page statistics controller.
 *
 * @author dqq
 * @date 2023 /2/8
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/homePage")
public class HomePageStatisticsController {

    @Resource
    private HomePageStatisticsService homePageStatisticsService;

    /**
     * 统计首页各项数据.
     *
     * @return the r
     */
    @GetMapping("/countItem")
    public R<Map<String, Object>> countItem() {
        log.info("countItem - 统计首页各项数据");
        return R.successDef(homePageStatisticsService.countItem());
    }

    /**
     * 统计展会服务费用.
     *
     * @param exhibitionManageId the exhibition manage id
     * @return the r
     */
    @GetMapping("/sum/serviceCategory/finance/{exhibitionManageId}")
    public R<List<Map<String, Object>>> sumServiceCategoryFinance(@PathVariable Long exhibitionManageId) {
        log.info("sumServiceCategoryFinance - 统计展会服务费用, exhibitionManageId={}", exhibitionManageId);
        return R.successDef(homePageStatisticsService.sumServiceCategoryFinance(exhibitionManageId));
    }

    /**
     * 查询展会进行的日期.
     *
     * @param month the month
     * @return the r
     */
    @GetMapping("/exhibition/date")
    public R<List<String>> queryExhibitionDate(@RequestParam("month") String month) {
        log.info("queryExhibitionDate - 查询展会进行的日期, month={}", month);
        return R.successDef(homePageStatisticsService.listExhibitionManageDate(month));
    }
}